package salvo.jesus.graph;

import java.io.Serializable;

/**
 * A vertex in a graph. This class encapsulates an object that the vertex will represent.
 * Hence, a Vertex can represent any object that extends java.lang.Object by simply
 * calling setObject() or specifying the objet on the constructor.
 *
 * Because Vertex.toString() will simply call the object's toString() method,
 * you may want to override the object's toString() method before you assign
 * the object to a Vertex.
 *
 * @author		Jesus M. Salvo Jr.
 */
public class Vertex implements Serializable {
  /**
    * The object that the vertex represents.
    */
  private Object	object;

  /**
    * Constructor that initializes this.object to null
    */
  public Vertex( ){
    object = null;
  }

  /**
    * Creates a new Vertex object that initializes this.object to newobject
    *
    * @param	newobject	The object that the Vertex will encapsulate
    */
  public Vertex( Object newobject ) {
    object = newobject;
  }

  /**
    * Getter method that returns the object that the Vertex represents
    *
    * @return	The object that this Vertex encapsulates
    */
  public Object getObject( ){
    return object;
  }

  /**
    * Setter method sets this.object to newobject
    */
  public void setObject( Object newobject ){
    this.object = newobject;
  }

  /**
    * Wrapper method that simply calls this.object.toString()
    *
    * @return   String representation of the Vertex object
    */
  public String toString( ){
    return this.object.toString();
  }
}
